package com.service.serviceImpl;

import com.entity.DataTablesOutput;
import com.mapper.UserMapper;
import com.service.IUserService;
import com.vo.userVo.*;
import org.mybatis.logging.Logger;
import org.mybatis.logging.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @Author hl
 * @Date
 * @Describe 用户相关功能
 */
@Service
public class UserServiceImpl implements IUserService {

    Logger logger = LoggerFactory.getLogger(IUserService.class);

    @Resource
    UserMapper userMapper;

    /**
     * 获取用户信息列表
     * @return
     */
    @Override
    public List<UserListResponseVo> getUserList(UserListRequestVo vo) {
        return userMapper.getUserList(vo);
    }


    /**
     * 赠送用户优惠券
     * @param vo
     */
    @Override
    public void giveUserCoupon(GiveUserCouponRequestVo vo) {
        vo.setCreateTime(LocalDateTime.now());
        userMapper.giveUserCoupon(vo);
    }

    /**
     * 赠送用户VIP
     */
    @Override
    public void giveUserVip(GiveUserVipRequestVo reqVo) {
        SendUserVipMapperReqVo vo = new SendUserVipMapperReqVo();
        vo.setId(reqVo.getId());
        vo.setUpdateTime(LocalDateTime.now());
        vo.setStartTime(LocalDateTime.now());
        //通过赠送时间计算结束时间
        vo.setEndTime(LocalDateTime.now().plusDays(reqVo.getVipTime()));
        userMapper.giveUserVip(vo);
    }
}
